﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Pages/Default.Master" AutoEventWireup="true"
    CodeBehind="Index.aspx.cs" Inherits="AUV5.Web.Pages.Index" ValidateRequest="false" %>

<%@ Import Namespace="AUV5.Model" %>
<%@ Import Namespace="AUV5.BLL" %>
<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<%@ Register Src="UCServiceList.ascx" TagName="UCServiceList" TagPrefix="uc1" %>
<%@ Register Src="UCWorkShare.ascx" TagName="UCWorkShare" TagPrefix="uc2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript">
        $(function () {
            //排序按钮的样式,及参数的的保留
            var r = new RegExp("(?:/orderby/([^\/]*))?(?:/category/([^\/]*))?(?:/key/([^\/]*))?$");
            var m = window.location.href.match(r);
            if (m != null) {
                var orderby = m[1] == undefined ? "" : m[1];
                var category = m[2] == undefined ? "" : m[2];
                var key = m[3] == undefined ? "" : m[3];
                if (orderby == "") {
                    orderby = Cookies.get("orderby") == "" ? "Random" : Cookies.get("orderby");
                }
                $('.subnav a').each(function () {
                    //排序方式
                    if (orderby != '') {
                        if (this.href.indexOf('/orderby/' + orderby) != -1) {
                            $(this).addClass('select');
                            Cookies.set('orderby', orderby);
                        }
                    }
                    if (category != '') {
                        this.href += "/category/" + category;
                    }
                    if (key != '') {
                        this.href += "/key/" + key;
                    }
                });
                $('.hotkey a').each(function () {
                    if (key != '') {
                        if (this.href.indexOf('/key/' + key) != -1) {
                            $(this).addClass('select');
                        }
                    }

                    var href = "";
                    if (orderby != "") {
                        href = "/orderby/" + orderby;
                    }
                    if (category != '') {
                        href += "/category/" + category;
                    }

                    this.href = href + "/key/" + $.trim($(this).text());
                });
            }
            //第一次使用
            $(".firsttime").colorbox({ inline: true, width: 880, height: 650 });

            //成果共享换页
            $('.mostpages').find('a').click(function (e) {
                $('.mostpages').find('.mostselected').removeClass('mostselected');
                $(this).addClass('mostselected');
                loadShare(4, this.id);
                preventDefault(e);
            });
        });


        //分享
        function loadShare(pagesize, pageindex) {
            $.ajax({
                url: '/Handler/ShareHandler.ashx',
                type: 'post',
                data: { pageindex: pageindex, pagesize: pagesize, iscover: true, maxcount: pagesize },
                beforeSend: function () {
                    $('.mostlist .process').text('loading...').show();
                },
                success: function (response) {
                    $('.mostlist .process').hide();
                    var res = eval(response);
                    if (res.length != 0) {

                        var container = $('.mostlist').find('ul');
                        container.fadeOut(1000, function () {
                            var html = "";
                            for (var i = 0; i < res.length; i++) {

                                if (i == pagesize - 1) {
                                    html += '<li class="nomar">';
                                }
                                else {
                                    html += "<li>";
                                }

                                html += res[i] + "</li>"
                            }
                            container.html(html).fadeIn(1000);
                        });
                    }
                }

            });
        }

   
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div style="display: none">
        <div class="pop_helpbar" id="helpbar">
            <p>
                <img src="/!images/pop_help.jpg" alt="第一次使用" /></p>
            <p class="btn_gotoreg">
                <a href="/Pages/Register.aspx">
                    <img src="/!images/btn_gotoregoff.jpg" id="Image23" onmouseover="MM_swapImage('Image23','','/!images/btn_gotoregon.jpg',23)"
                        onmouseout="MM_swapImgRestore()" alt="快来感受AUV" /></a></p>
        </div>
    </div>
    <div class="banner">
        <img id="banner" src="" alt="" title="" />
        <script type="text/javascript">
            var index = Math.floor(Math.random() * 3 + 1);
            $('#banner').attr('src', '/!images/banner_pic' + index + '.jpg');
        </script>
        <p class="btn_help">
            <a class="firsttime" href="#helpbar">
                <img alt="第一次使用" src="/!images/btn_help.png" /></a>
        </p>
    </div>
    <p class="clear">
    </p>
    <div id="divShare" runat="server">
        <p class="title_most">
            <img src="/!images/title_most.png" /></p>
        <div class="mostlist" style="position: relative">
            <span class="process" style="font-size: 13px; font-weight: bolder; position: absolute;
                top: 130px; left: 350px;"></span>
            <ul>
                <asp:Repeater ID="repShare" runat="server">
                    <ItemTemplate>
                        <li <%#Container.ItemIndex == 3 ? "class='nomar'" : ""%>>
                            <uc2:UCWorkShare ID="UCWorkShare1" runat="server" DataSource="<%#(Container.DataItem as WorksShare) %>"
                                IsCover="true" />
                        </li>
                    </ItemTemplate>
                </asp:Repeater>
                <li class="nomar">
                    <uc2:UCWorkShare ID="MoreShare" runat="server" IsCover="true" ShowCategory="true"
                        Visible="false" />
                </li>
            </ul>
            <p class="clear">
            </p>
        </div>
        <p class="clear">
        </p>
        <p class="mostpages">
            <a href="" class="mostselected" id="1"></a><a href="" id="2"></a><a href="" id="3">
            </a>
        </p>
    </div>
    <p class="clear">
    </p>
    <div class="serviceadd" <%=base.IsVerified?"":"style='display:none'" %>>
        <div class="serviceaddimg">
            <img alt="" src='<%=base.IsVerified?base.VerifiedInfo.User.PhotoPath:""%>' />
        </div>
        <div class="serviceaddtxt">
            <div class="serviceaddbg">
                <p>
                    我可以</p>
                <div class="serviceinput">
                    <input id='title' type="text" name="" value="" />
                    <span><a href="/Pages/ServiceAdd.aspx" onclick="javascript:this.href=this.href+'?title='+$('#title').val()">
                        <img src="/!images/btn_puboff.jpg" id="Image5" onmouseover="MM_swapImage('Image5','','/!images/btn_pubon.jpg',5)"
                            onmouseout="MM_swapImgRestore()" alt="发布" /></a></span>
                </div>
                <p class="clear">
                </p>
            </div>
        </div>
    </div>
    <p class="clear">
    </p>
    <div class="hotkey">
        <%foreach (var item in GetHotKey())
          {%>
        <a href="/key/<%=item.ToString()%>">
            <%=item.ToString()%></a>
        <%}%>
    </div>
    <div class="subnav">
        <span class="order">排序方式</span>
        <ul>
            <li class="frist"><a href="/orderby/Random">随意</a></li>
            <li><a href="/orderby/Newest">最新</a></li>
            <li><a href="/orderby/Popularity">最流行</a></li>
            <li><a href="/orderby/Hotsale">最热卖</a></li>
            <li class="last"><a href="/orderby/Rating">最多好评</a></li>
        </ul>
    </div>
    <div class="list">
        <ul>
            <!--Service List B-->
            <uc1:UCServiceList ID="UCServiceList1" runat="server" />
            <!--Service List E-->
        </ul>
        <div class="pages">
            <webdiyer:AspNetPager ID="AspNetPager1" runat="server" OnPageChanged="AspNetPager1_PageChanged"
                CustomInfoHTML="共%PageCount%页，当前为第%CurrentPageIndex%页" PageIndexBoxType="DropDownList"
                PagingButtonLayoutType="Span" SubmitButtonText="Go" TextAfterPageIndexBox="页"
                TextBeforePageIndexBox="转到" PageSize="15" PagingButtonSpacing="" CurrentPageButtonClass="currentpage"
                ButtonImageExtension=".jpg" ImagePath="/!images/" ShowPageIndexBox="Never">
            </webdiyer:AspNetPager>
        </div>
    </div>
</asp:Content>
